//
//  MYGPatientTableViewCell.swift
//  MYDoctor
//
//  Created by 王振明 on 2024/4/18.
//

import UIKit

class MYGPatientTableViewCell: UITableViewCell {
    var modelDa:MYGMyPatientModel = MYGMyPatientModel(){
        didSet{
            headerImageBV.sd_setImage(with: URL(string: modelDa.patient.avatar),placeholderImage: UIImage(named: "head"))
            nameLabel.text = modelDa.patient.name
            contentLabel.text = modelDa.patient.cityString
            self.sexLabel.text = "\(modelDa.patient.birthday.getAge())"
            if modelDa.patient.gender == 0 {
                self.sexImage.image = UIImage(named: "common_male")
            }else {
                self.sexImage.image = UIImage(named: "common_female")
            }
            stateLabel.text = "未激活"
        }
    }
    var doctorModel:MYGFriendsModel = MYGFriendsModel(){
        didSet{
            headerImageBV.sd_setImage(with: URL(string: doctorModel.doctor.avatar))
            nameLabel.text = doctorModel.doctor.name
//            contentLabel.text = doctorModel.doctor.cityString
//            self.sexLabel.text = "\(doctorModel.doctor.birthday.getAge())"
//            if doctorModel.patient.gender == 0 {
//                self.sexImage.image = UIImage(named: "common_male")
//            }else {
//                self.sexImage.image = UIImage(named: "common_female")
//            }
            stateLabel.text = "未激活"
        }
    }
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        initUI()
    }
    private func initUI(){
        contentView.addSubview(headerImageBV)
        headerImageBV.snp.makeConstraints { make in
            make.centerY.equalToSuperview()
            make.left.equalToSuperview().offset(20)
            make.size.equalTo(CGSize(width: 50, height: 50))
        }
        contentView.addSubview(nameLabel)
        nameLabel.snp.makeConstraints { make in
            make.top.equalToSuperview().offset(22)
            make.left.equalTo(headerImageBV.snp.right).offset(11)
            make.height.equalTo(22.5)
        }
        contentView.addSubview(sexView)
        sexView.snp.makeConstraints { make in
            make.left.equalTo(nameLabel.snp.right).offset(5.5)
            make.centerY.equalTo(nameLabel)
            make.height.equalTo(16)
        }
        sexView.addSubview(sexImage)
        sexImage.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(4)
            make.centerY.equalToSuperview()
            make.size.equalTo(CGSize(width: 11, height: 11))
        }
        sexView.addSubview(sexLabel)
        sexLabel.snp.makeConstraints { make in
            make.left.equalTo(sexImage.snp.right).offset(4)
            make.centerY.equalToSuperview()
            make.height.equalTo(12)
            make.right.equalToSuperview().offset(-4)
        }
        contentView.addSubview(stateLabel)
        stateLabel.snp.makeConstraints { make in
            make.left.equalTo(headerImageBV.snp.right).offset(11)
            make.top.equalTo(nameLabel.snp.bottom).offset(5)
            make.height.equalTo(18)
        }
        contentView.addSubview(contentLabel)
        contentLabel.snp.makeConstraints { make in
            make.top.equalTo(nameLabel.snp.bottom).offset(5)
            make.left.equalTo(headerImageBV.snp.right).offset(11)
            make.height.equalTo(18.5)
        }
        contentView.addSubview(lineView)
        lineView.snp.makeConstraints { make in
            make.bottom.equalToSuperview()
            make.left.equalTo(contentLabel.snp.left)
            make.height.equalTo(0.5)
            make.right.equalToSuperview().offset(-30)
        }
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var headerImageBV: UIImageView = {
        let cont = UIImageView()
        cont.layer.cornerRadius = 25
        cont.layer.masksToBounds = true
        cont.contentMode = .scaleAspectFill
        return cont
    }()
    lazy var nameLabel: UILabel = {
        let cont = UILabel()
        cont.text = ""
        cont.font = .medium(16)
        cont.textColor = .rgba(44, 44, 44)
        return cont
    }()
    lazy var contentLabel: UILabel = {
        let cont = UILabel()
        cont.text = ""
        cont.font = .regular(13)
        cont.textColor = .rgba(126, 126, 126)
        return cont
    }()
    lazy var lineView: UIView = {
        let cont = UIView()
        cont.backgroundColor = .rgba(238, 238, 238, 1)
        return cont
    }()
    private lazy var sexView: UIView = {
        let cont = UIView()
        cont.layer.masksToBounds = true
        cont.layer.cornerRadius = 4
        cont.backgroundColor = .rgba(105, 133, 227)
        return cont
    }()
    private lazy var sexImage: UIImageView = {
        let cont = UIImageView()
        cont.image = UIImage(named: "common_male")
        return cont
    }()
    private lazy var sexLabel: UILabel = {
        let cont = UILabel()
        cont.text = "12岁"
        cont.font = .regular(11)
        cont.textColor = .rgba(255, 255, 255)
        return cont
    }()
    lazy var stateLabel: UILabel = {
        let cont = UILabel()
        cont.text = ""
        cont.font = .regular(12)
        cont.textColor = .rgba(110, 110, 110, 1)
        return cont
    }()
}
